package cn.weiyang.service.impl;

import cn.weiyang.dao.EmpMapper;
import cn.weiyang.model.Emp;
import cn.weiyang.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017-7-20.
 */
@Service
public class EmpServiceImpl implements IEmpService {
    @Resource
    private EmpMapper empMapper;
    /**
     * 查询所有员工(配置事务时需要抛出异常，查询不需要配置事务，此处只是为了演示)
     * @return
     */
    @Transactional
    public List<Emp> findAllEmp() {
        try {
            return empMapper.findAllEmp();
        }catch (Exception e){
            e.printStackTrace();
        }
            return null;


    }
}
